home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2007 June/July / Windows News Hors série Numéro 34 juin juillet 2007.iso / Rédaction / Astuces Internet / test-commentaire.bak < prev    next >
Encoding:
Text File  |  2006-11-30  |  10.7 KB  |  363 lines

  1. <html>
  2.  
  3. <head>
  4. <script language="JavaScript"><!--
  5.  
  6. 'commentaire
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. // --></script>
  38. <script language="JavaScript">
  39. <!--
  40. function namosw_page_left(element) 
  41. {
  42.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  43.  
  44.   if (is_ns4) {
  45.     x = element.pageX;
  46.   } else {
  47.     x = element.offsetLeft;
  48.     for (el = element.offsetParent; el; el = el.offsetParent)
  49.       x += el.offsetLeft;
  50.   }
  51.   return x;
  52. }
  53.  
  54. function namosw_page_top(element) 
  55. {
  56.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  57.  
  58.   if (is_ns4) {
  59.     y = element.pageY;
  60.   } else {
  61.     y = element.offsetTop;
  62.     for (el = element.offsetParent; el; el = el.offsetParent)
  63.       y += el.offsetTop;
  64.   }
  65.   return y;
  66. }
  67.  
  68. function namosw_page_right(el) {
  69.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  70.  
  71.   wid =  (is_ns4) ? window.innerWidth : document.body.offsetWidth;
  72.   return wid - namosw_page_left(el);
  73. }
  74.  
  75. function namosw_page_bottom(el) {
  76.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  77.  
  78.   hei =  (is_ns4) ? window.innerHeight : document.body.offsetHeight;
  79.   return hei - namosw_page_top(el);
  80. }
  81.  
  82. function namosw_set_visible(el, flag) {
  83.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  84.  
  85.   if (is_ns4) {
  86.     el.visibility = flag ? 'show' : 'hide';
  87.   } else {
  88.     el.style.visibility = flag ? 'visible' : 'hidden';
  89.   }
  90. }
  91.  
  92. function namosw_set_pos(el, x, y)
  93. {
  94.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  95.   var is_ns6 = navigator.appName.indexOf('Netscape', 0) != -1 && document.getElementById;
  96.  
  97.   if (is_ns4) {
  98.     el.left = x;
  99.     el.top  = y;
  100.   } else if (is_ns6) {
  101.     el.style.left = x;
  102.     el.style.top  = y;
  103.   } else {
  104.     el.style.pixelLeft = x;
  105.     el.style.pixelTop  = y;
  106.   }
  107. }
  108.  
  109. function namosw_left(el) {
  110.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  111.   var is_ns6 = navigator.appName.indexOf('Netscape', 0) != -1 && document.getElementById;
  112.  
  113.   if (is_ns4)      return el.left;
  114.   else if (is_ns6) return parseInt(el.style.left);
  115.   else             return el.style.pixelLeft;
  116. }
  117.  
  118. function namosw_top(el) {
  119.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  120.   var is_ns6 = navigator.appName.indexOf('Netscape', 0) != -1 && document.getElementById;
  121.  
  122.   if (is_ns4)      return el.top;
  123.   else if (is_ns6) return parseInt(el.style.top);
  124.   else             return el.style.pixelTop;
  125. }
  126.  
  127. function namosw_is_relative(el) {
  128.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  129.  
  130.   if (is_ns4) return el.position == 'relative';
  131.   else        return el.style.position == 'relative';
  132. }
  133.  
  134. function namosw_is_space(c)
  135. {
  136.   return (c == ' ' || c == '\t' || c == '\r' || c == '\n');
  137. }
  138.  
  139. function namosw_process_byword(list, index)
  140. {
  141.   var el = list[index];
  142.   if (navigator.appName.indexOf('Netscape', 0) != -1)
  143.     return;
  144.   if (!el)
  145.     return;
  146.   if (el.byword == false)
  147.     return;
  148.  
  149.   var dest = "";
  150.   var src = el.innerHTML;
  151.   var objNum = document.NamoAnimationObjects.length;
  152.   var wordi = 0, i = 0, mark;
  153.   while (i < src.length) {
  154.     mark = i;
  155.     while (i < src.length) {
  156.       while (i < src.length && namosw_is_space(src.charAt(i))) i++;
  157.       if    (i < src.length && src.charAt(i) != '<') break;
  158.       while (i < src.length && src.charAt(i) != '>') i++;
  159.       if    (i < src.length && src.charAt(i) == '>') i++;
  160.     }
  161.     dest += src.substring(mark, i);
  162.     if (i >= src.length) break;
  163.     dest += '<span id=\"' + el.name + 'word' + (wordi+1) + '\" style=\"position:relative\">';
  164.     mark = i;
  165.     while (i < src.length && !namosw_is_space(src.charAt(i)) && src.charAt(i) != '<') i++;
  166.     while (i < src.length && namosw_is_space(src.charAt(i)) == ' ') i++;
  167.     if (el.byword == false) while (i < src.length && src.charAt(i) != '<') i++;
  168.     dest += src.substring(mark, i);
  169.     dest += '</span>';
  170.     wordi++;
  171.   }
  172.   el.innerHTML = dest;
  173.   el.posLeft   = 0;
  174.   el.style.visibility = 'visible';
  175.  
  176.   list[index] = namosw_new_animation_object(el.name+'word1', el.startCondObj, el.startCondTime, 
  177. el.startXPos, el.startYPos, el.pathType, false, el.zoom, el.stepNum);
  178.   for (i = 1; i < wordi; i++) {
  179.     list[objNum+i-1] = namosw_new_animation_object(el.name+'word'+(i+1), (el.byword ? (el.name+'word'+i) : el.startCondObj), (el.byword ? 0 : el.startCondTime), el.startXPos, el.startYPos, el.pathType, false, el.zoom, el.stepNum);
  180.     list[objNum+i-1].style.posLeft = 0;
  181.     list[objNum+i-1].style.visibility = 'visible';
  182.   }
  183.   el.startCondTime = -1;
  184. }
  185.  
  186. function namosw_new_animation_object(name, obj, time, xpos, ypos, path, byword, zoom, stepNum) 
  187. {
  188.   if (name == '') return 0;
  189.  
  190.   var is_ns4 = navigator.appName.indexOf('Netscape', 0) != -1 && !document.getElementById;
  191.   var is_ns6 = navigator.appName.indexOf('Netscape', 0) != -1 && document.getElementById;
  192.  
  193.   var object;
  194.   if (is_ns4)      object = eval("document." + name);
  195.   else if (is_ns6) object = document.getElementById(name);
  196.   else             object = document.all(name);
  197.  
  198.   if (!object) return 0 ;
  199.  
  200.   object.name     = name;
  201.   object.startCondObj  = obj;
  202.   object.startCondTime = time;
  203.   object.startXPos     = xpos;     // left, center, right
  204.   object.startYPos     = ypos;     // top,  center, bottom
  205.   object.pathType      = path;     // line, arc, spiral
  206.   object.byword        = byword;   // true, false
  207.   object.zoom          = zoom;
  208.   object.stepNum       = stepNum;
  209.   return object;
  210. }
  211.  
  212. function namosw_animate(str) 
  213. {
  214.   var live_object_num = 0;
  215.   for (var i = 0; i < document.NamoAnimationObjects.length; i++) {
  216.     var el = document.NamoAnimationObjects[i];
  217.     if (!el) continue;
  218.     if (el.countDown > 0) {
  219.       el.countDown = (0 < el.countDown-10) ? el.countDown-10 : 0;
  220.       live_object_num++;
  221.       continue;
  222.     }
  223.     if (el.countDown < 0)
  224.       continue;
  225.  
  226.     if (el.pathType == 'line') {
  227.       newx = el.sx + el.step * (el.ex - el.sx) / el.stepNum;
  228.       newy = el.sy + el.step * (el.ey - el.sy) / el.stepNum;
  229.     } else if (el.pathType == 'arc') {
  230.       linex = el.sx + el.step * (el.ex - el.sx) / el.stepNum;
  231.       liney = el.sy + el.step * (el.ey - el.sy) / el.stepNum;
  232.  
  233.       x = (el.ex + el.sx) / 2;
  234.       y = (el.ey + el.sy) / 2;
  235.       sinv = Math.sin(Math.PI*el.step/el.stepNum*(el.ex-el.sx > 0 ? -1:1));
  236.       cosv = Math.cos(Math.PI*el.step/el.stepNum);
  237.       newx = ((cosv*(el.sx-x) - sinv*(el.sy-y) + x) + linex) / 2;
  238.       newy = ((sinv*(el.sx-x) + cosv*(el.sy-y) + y) + liney) / 2;
  239.     } else if (el.pathType == 'spiral') {
  240.       sinv = Math.sin(2*Math.PI*el.step/el.stepNum);
  241.       cosv = Math.cos(2*Math.PI*el.step/el.stepNum);
  242.       r = (el.stepNum-el.step)/el.stepNum;
  243.       newx = el.ex + (cosv*(el.sx-el.ex) - sinv*(el.sy-el.ey))*r;
  244.       newy = el.ey + (sinv*(el.sx-el.ex) + cosv*(el.sy-el.ey))*r;
  245.     }
  246.       if (el.style) {
  247.       if (el.zoom == 'zoomin')
  248.         el.style.fontSize = 50+50*el.step/el.stepNum + '%';
  249.       else if (el.zoom == 'zoomout')
  250.         el.style.fontSize = 200-100*el.step/el.stepNum + '%';
  251.     }
  252.     namosw_set_pos(el, newx, newy);
  253.     namosw_set_visible(el, true);
  254.  
  255.     if (el.step++ == el.stepNum) {
  256.       namosw_set_pos(el, el.ex, el.ey);
  257.       el.step = 0;
  258.       el.countDown = -1;
  259.       // trigger other object(self can be trigger)
  260.       for (var j = 0; j < document.NamoAnimationObjects.length; j++) {
  261.         var obj = document.NamoAnimationObjects[j];
  262.         if (obj.countDown < 0 && obj.startCondObj == el.name) {
  263.           obj.countDown = obj.startCondTime;
  264.           live_object_num++;
  265.           if (i < j) {
  266.             obj.countDown += 10;
  267.             live_object_num--;
  268.           }
  269.         }
  270.       }
  271.     } else {
  272.       live_object_num++;
  273.     }
  274.   }
  275.   if (live_object_num > 0)
  276.     window.setTimeout("namosw_animate();", 10);
  277. }
  278.  
  279. function namosw_init_scrolltext()
  280. {
  281.   list = new Array();
  282.   for (var i = 0, top = 0; i < namosw_init_scrolltext.arguments.length; i += 2) {
  283.     obj = eval('document.'+namosw_init_scrolltext.arguments[i]);
  284.     if (obj == null) continue;
  285.     list[top++] = obj;
  286.     for (str = '', j = 0; j < namosw_init_scrolltext.arguments[i+1]; j++)
  287.       str += ' ';
  288.     str += obj.value;
  289.     obj.value = str;
  290.   }
  291.   if (top > 0) {
  292.     document.namosw_scrolltext_list = list;
  293.     setTimeout('namosw_scrolltext()', 100);
  294.   }
  295. }
  296.  
  297. function namosw_scrolltext()
  298. {
  299.   for (i = 0; i < document.namosw_scrolltext_list.length; i++) {
  300.     obj   = document.namosw_scrolltext_list[i];
  301.     str   = obj.value.substring(1, obj.value.length);
  302.     str  += obj.value.substring(0, 1);
  303.     obj.value = str;
  304.   }
  305.   setTimeout('namosw_scrolltext()', 100);
  306. }
  307.  
  308. function namosw_init_animation()
  309. {
  310.   var i    = 0;
  311.   var list = new Array;
  312.  
  313.   list[i++] = namosw_new_animation_object('alayer1', null, 0, 'left', 'top', 'line', false, null, 20);
  314.   document.NamoAnimationObjects = list;
  315.  
  316.   var length = list.length;
  317.   for (i = 0; i < length; i++)
  318.     namosw_process_byword(list, i);
  319.  
  320.   for (i = 0; i < list.length; i++) {
  321.     if (!list[i]) continue;
  322.     list[i].countDown = (list[i].startCondObj == null) ? list[i].startCondTime : -1;
  323.     list[i].step      = 0;
  324.     list[i].sx        = (list[i].startXPos == 'left')  ? -namosw_page_left(list[i])  :
  325.                (list[i].startXPos == 'right') ?  namosw_page_right(list[i]) : 0;
  326.     list[i].sy        = (list[i].startYPos == 'top')   ? -namosw_page_top(list[i])   :
  327.                (list[i].startYPos == 'bottom')?  namosw_page_bottom(list[i]): 0;
  328.     list[i].ex      = 0;
  329.     list[i].ey       = 0;
  330.  
  331.     if (!namosw_is_relative(list[i])) {
  332.       list[i].sx += namosw_left(list[i]);
  333.       list[i].sy += namosw_top(list[i]);
  334.       list[i].ex += namosw_left(list[i]);
  335.       list[i].ey += namosw_top(list[i]);
  336.     }
  337.     if (list[i].pathType == 'spiral') {
  338.       list[i].sx = Math.max(-200+list[i].ex, Math.min(200+list[i].ex, list[i].sx));
  339.       list[i].sy = Math.max(-200+list[i].ey, Math.min(200+list[i].ey, list[i].sy));
  340.     }
  341.     namosw_set_pos(list[i], list[i].sx, list[i].sy);
  342.     namosw_set_visible(list[i], false);
  343.   }
  344.   window.setTimeout("namosw_animate();", 10);
  345. }
  346.  
  347. // --></script>
  348. </head>
  349.  
  350. <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red" OnLoad="namosw_init_animation(); namosw_init_scrolltext('form1.scrolltext1', 50)">
  351. <!--Cette page Web a ΘtΘ crΘΘe par le roi des Webmasters-->
  352. <p>
  353. Une page Web toute simple.</p>
  354. <form name="form1">
  355. <p>
  356. <input type="text" name="scrolltext1" value="Ce texte file" size="40">
  357. </p>
  358. </form>
  359. <p id="alayer1" style="position:relative; visibility:hidden;"> </p>
  360. </body>
  361.  
  362. </html>
  363.